<template>
  <div class="container" ref="mainCon">
    <topTitle :titleText="titleText"></topTitle>
    <div class="mainCon" style="top: 198px">
      <!-- 搜索框 -->
      <el-row class="searchBox searchInputWidth">
        <el-form :inline="true" :model="filterField">
          <el-col :lg="8" :xl="6">
            <el-form-item label="用户名" class="row-padding-bottom">
              <el-input
                placeholder="请输入用户名"
                clearable
                v-model="filterField.username"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="8" :xl="6">
            <el-form-item label="姓名" class="row-padding-bottom">
              <el-input
                placeholder="请输入姓名"
                clearable
                v-model="filterField.name"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-form-item>
            <el-button
              type="primary"
              icon="icon iconfont iconchazhao1"
              @click="searchList"
              class="searchBtn"
            >
              <span>搜索</span>
            </el-button>
          </el-form-item>
          <el-form-item class="fr">
            <el-button
              type="primary"
              class="commonBut saveBtn funComBut"
              icon="icon iconfont icontianjia"
              @click="skipUserTab('add', 'first')"
            >
              <span class="opetareText">新增用户</span>
            </el-button>
          </el-form-item>
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <!-- 表格 -->
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          :data="tableList"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          v-loading="loading"
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column
            prop="username"
            label="用户名"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <!-- <el-table-column  prop="name"  label="姓名"  align="center"  :formatter="formatTd"></el-table-column> -->
          <el-table-column label="姓名" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.name"
                :columnName="'name'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="tel"
            label="手机号"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="inputTypeName"
            label="用户类型"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="enabledName"
            label="状态"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            label="操作"
            align="center"
            :formatter="formatTd"
            min-width="200"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="
                  skipUserTab(
                    'detail',
                    'first',
                    scope.row.id,
                    scope.row.typeDesc,
                    scope.row.bankSiteId
                  )
                "
                >查看账号</el-link
              >
              <el-link
                type="primary"
                @click="
                  skipUserTab(
                    'detail',
                    'third',
                    scope.row.id,
                    scope.row.typeDesc,
                    scope.row.bankSiteId
                  )
                "
                >查看角色</el-link
              >
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'
export default {
  name: 'inputUserManage',
  mixins: [scrollTable],
  data() {
    return {
      titleText: '数据接入用户',
      tableList: [],
      requestUrl: 'api-m/inputUser/base/v1/page',
      isShow: false, //列表加载
      loading: true,
      filterField: {
        username: '',
        name: '', //新增姓名查询
      },
      isShowAdd: '',
      isShowDetail: '',
    }
  },
  created() {
    this.isShowAdd = this.$store.state.buttonLimitsArr.indexOf('user:add') > -1
    this.isShowDetail =
      this.$store.state.buttonLimitsArr.indexOf('user:detail') > -1
  },
  mounted() {
    var that = this
    this.$nextTick(function () {
      that.$refs.pagination.getTableListData()
    })
  },
  methods: {
    //新增用户/查看用户/查看资料/查看角色
    skipUserTab(eventType, itemTab, id, typeDesc, bankSiteId) {
      this.$router.push({
        path: '/home/interfacePlatform/inputUserManageTab',
        name: 'inputUserManageTab',
        query: {
          eventType: eventType,
          itemTab: itemTab,
          id: id,
          bankSiteId: bankSiteId,
          typeDesc: typeDesc,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/interfacePlatform/inputUserManageList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      var that = this
      this.$nextTick(function () {
        that.$refs.pagination.getTableListData()
      })
    },
  },
}
</script>

<style lang="less" scoped>
.operation {
  float: right;
  padding: 8px 12px 8px 12px;
  border-radius: 5px;
  background: rgb(0, 174, 255);
  color: white;
  font: 14px SourceHanSansCN-Medium;
  cursor: pointer;
}
.title {
  padding-left: 4px;
  padding-top: 10px;
  margin-bottom: -10px;
  font: bold 18px/50px Microsoft YaHei;
}
@import '../../../static/css/filterArea.less';
</style>
